$(function () {
    
    $("header").load("./header.html", () => {

    });
    $("footer").load("./footer.html", () => {

    });
    $('#cxslide_y').cxSlide({
        type: 'y'
    });
    $('img').lazyload({
        placeholder : "./images/lazyload.jpg",
        effect:"fadeIn",
        threshold:170,
        // failurelimit:10,
    });

    $('img').on("mouseenter",function(){
        $(this).stop().fadeTo(200,0.5)
    }).on("mouseleave",function(){
        $(this).stop().fadeTo(200,1)
    })

    $.ajax({
        url:"./api/goods",
        type:"get",
        dataType:"json"
    }).done((res)=>{
        var strHtml = "";
        res.forEach(el => {
            strHtml +=`
            <li>
            <a href="./goodsInfo.html?id=${el.p_id}"><img class="pic" src="${el.p_img_index}" />
            <p>${el.p_name}</p>
            </a>
            <p>售价$:<span>${el.p_price}</span>元</p>
            </li>
             `
        });
        $(".s_ajax").find("ul").html(strHtml);
    })
});